<?php
/* 
 * FilePath: rwmsp-app\Consumer.php
 * Created: lijianwei 2021-05-26 11:01:16
 * -----
 * Last Modified: lijianwei 2021-05-28 13:22:08
 * -----
 * Copyright (c) 2016-2021 Rongwen Tech Ltd.
 * -----
 */

//生产消费者模式 demo

// 消息生产者代码
$rk = new \RdKafka\Producer();
$rk->setLogLevel(LOG_DEBUG);
$rk->addBrokers("127.0.0.1");

$topic = $rk->newTopic("TesTopic");

for ($i = 0; $i < 10; $i++) {
    $msg = "Msg $i ".time();
    $topic->produce(RD_KAFKA_PARTITION_UA, 0, $msg);
    sleep(1);
}
